home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
L' Effet Pommier 3
/
L'Effet Pommier - Volume 03.iso
/
Programmation
/
Alpha ƒ
/
Tcl
/
SystemCode
/
codeWarrior.tcl
< prev
next >
Wrap
Text File
|
1996-01-26
|
11KB
|
408 lines
#=== nowrap =====================================================================
#
# CodeWarrior Interaction
#
# Metrowerks currently has an incomplete appleevent interface.
# Apple events can be used to direct CodeWarrior to compile
# or add individual files, make the project, etc. However,
# there is currently no provision to report specific errors
# back to the controller.
#
#================================================================================
proc cwarriorMenu {} {}
menu -n "$cwarriorMenu" -p codeWarriorProc {
"help"
"/-<UswitchTo"
{menu -n werksFlags -p werksProc {
"debugger"
"switchWhenCompiling"
}}
"createFileset"
"(-"
"addFile"
"/K<Ucompile"
"compileFiles"
"checkSyntax"
"precompile╔"
"(-"
"/U<Uupdate"
"/M<Umake"
"(-"
"/D<UgotoDebugger"
"/B<UsetBreakpoint"
"clearBreakpoint"
"/J<UshowSource"
"(-"
"/N<UnextError"
"/R<Urun"
}
if {![info exists cwdebugger]} {set cwdebugger 0}
if {![info exists cwswitchWhenCompiling]} {set cwswitchWhenCompiling 1}
markMenuItem werksFlags debugger $cwdebugger
markMenuItem werksFlags switchWhenCompiling $cwswitchWhenCompiling
proc cwhelp {} {
global HOME
edit -r "$HOME:Help:CodeWarrior"
}
proc werksProc {menu item} {
global cw$item modifiedVars
set cw$item [expr -1 * ([set cw$item] - 1)]
markMenuItem werksFlags $item [set cw$item]
lappend modifiedVars cw$item
}
set CWCLASS MMPR
set CDCLASS MWDB
proc cwnextError {} {
nextMatch "*Compiler Errors*"
}
proc dispErr {{win "* Compiler Errors *"}} {
if {[string length $win]} {
set text [getText -w $win [getPos -w $win] [selEnd -w $win]]
if {[regexp {(Line.*)░} $text dummy sub]} {
message "$sub"
}
}
}
proc codeWarriorProc {menu item} {
cw$item
}
proc cwswitchTo {} {
global CODEWarrior
checkCw
switchTo $CODEWarrior
}
proc cwmake {} {killCwErrors; cwDo Make}
proc cwupdate {} {cwDo UpdP}
proc cwDo {param} {
global CODEWarrior CWCLASS ALPHA
checkCw
switchTo $CODEWarrior
if {[string length [set res [AEBuild -r -t 500000 $CODEWarrior $CWCLASS $param "Errs" "bool(╟01╚)"]]]} {
warriorErrors $res
}
}
proc cwrun {} {
global CODEWarrior CWCLASS ALPHA cwdebugger
checkCw
killCwErrors
set bug $cwdebugger
switchTo $CODEWarrior
if {[string length [set res [AEBuild -r -t 500000 $CODEWarrior $CWCLASS RunP "Errs" "bool(╟01╚)" DeBg $bug]]]} {
warriorErrors $res
}
}
proc cwprecompile {} {
global CODEWarrior CWCLASS res
checkCw
set fname [lindex [winNames -f] 0]
set targ [putfile "Precompile target:"]
switchTo $CODEWarrior
if {[string length [set res [AEBuild $CODEWarrior $CWCLASS PreC "----" [makeAlis $fname] "Errs" "bool(╟01╚)" Targ [makeAlis $targ]]]] > 40} {
warriorErrors $res
} else {
if {[regexp {errn:([-0-9]+)} $res dummy errno]} {
message "Error number: $errno"
}
}
}
proc cwaddFile {} {
global CODEWarrior CWCLASS
checkCw
switchTo $CODEWarrior
set fname [lindex [winNames -f] 0]
set res [AEBuild -t 500000 -q $CODEWarrior $CWCLASS AddF "----" [makeAlis $fname]]
}
proc cwcheckSyntax {} {
global CODEWarrior CWCLASS res
checkCw
# switchTo $CODEWarrior
set fname [lindex [winNames -f] 0]
if {[string length [set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS Chek "----" [concat {[alis(╟} [coerce TEXT $fname -x alis] {╚)]}] "Errs" "bool(╟01╚)"]]] > 40} {
warriorErrors $res
}
}
proc killCwErrors {} {
set wins [winNames]
if {[set res [lsearch $wins "*Compiler Errors*"]] >= 0} {
set name [lindex $wins $res]
bringToFront $name
killWindow
}
}
proc cwcompile {} {
global CODEWarrior CWCLASS res ALPHA cwswitchWhenCompiling
save
checkCw
set fname [lindex [winNames -f] 0]
killCwErrors
if {$cwswitchWhenCompiling} {
switchTo $CODEWarrior
}
if {[string length [set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS Comp "----" [makeAlis $fname] "Errs" "bool(╟01╚)"]]] > 40} {
warriorErrors $res
}
switchTo $ALPHA
}
proc cwcompileFiles {} {
global CODEWarrior CWCLASS res ALPHA winModes
saveAll
checkCw
set files {}
set wins [winNames -f]
set md $winModes([lindex $wins 0])
foreach w $wins {
if {$md == $winModes($w)} {
lappend files $w
}
}
killCwErrors
switchTo $CODEWarrior
if {[string length [set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS Comp "----" [eval makeAlises $files] "Errs" "bool(╟01╚)"]]] > 40} {
warriorErrors $res
}
switchTo $ALPHA
}
proc cwGetFiles {} {
global CODEWarrior CWCLASS
checkCw
set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS GSeg]
regexp {\[(.*)\]} $res dummy segs
regsub -all {, Seg} $segs {Ñ} segs
set ind 1
foreach seg [split $segs {Ñ}] {
regexp {NumF:([0-9]+)} $seg dummy num
while {$num > 0} {
set res [AEBuild -t 500000 -r $CODEWarrior $CWCLASS GFil "----" "long($num)" Segm "long($ind)"]
if {[regexp {FTxt} $res]} {
regexp {╟(.*)╚} $res dummy spec
set f [specToPathName $spec]
message $f
lappend files $f
}
incr num -1
}
incr ind
}
return $files
}
proc createWarriorFileset {} {
cwcreateFileset
}
proc cwcreateFileset {} {
global fileSets
global currFileSet
set name [prompt "Fileset name? " "CodeWarrior"]
set fileSets($name) [lsort -command sortByTail [cwGetFiles]]
addMenuItem -m choose $name
set currFileSet $name
if {[askyesno "Save project fileset?"] == "yes"} {
addArrDef fileSets $name $fileSets($name)
}
rebuildFilesetMenu
}
# the error reply from CodeWarrior looks like this
# [ErrM{ErrT:ErCW, ErrS:╥function declaration hides inherited virtual function╙, file:fss (╟FFFB000014371443536D617274537464506F7075704D656E752E6800000000000000000000000000000000000000000000000000000000000000000000000000000000000000╚), ErrL:64}, ...]
#
# ErrT is the error type parameter
# ErCW indicates a warning
# ErCE indicates an error
# Improvements by jdunning@cs.Princeton.EDU (John Dunning)
proc warriorErrors {res} {
global winModes tileLeft tileTop tileWidth errorHeight
if {[regexp {\[.*\]} $res res]} {
# trim off the outside brackets
set res [string trim $res {[]}]
# replace all the returns in the error list with spaces. this is
# necessary because CW 7.0 can return multi-line error messages,
# which aren't processed correctly by this function.
regsub -all "\r" $res " " res
# delete the first ErrM, and replace the remaining ones (and the preceeding commas)
# with returns
regsub {ErrM} $res "" res
regsub -all {, ErrM} $res "\r" res
set text ""
set errors 0
set warnings 0
set messages 0
set link 0
# split the string into separate lines, one error per line. only process
# process the first 101 errors
foreach err [lrange [split $res "\r"] 0 100] {
# the last two letters in ErrT:Er.. signal whether it's a compile (C) or link (L)
# error and whether it's an error (E) or a warning (W). stick the rest of
# the error message back into err.
if {[regexp {ErrT:Er(.)(.),[ \t]*(.*)} $err unused compileOrLink errorOrWarning err]} {
if {$errorOrWarning == "E"} {
# mark actual errors with a bullet
append text " Ñ "
incr errors
} else {
# mark warnings with a delta
append text " ╞ "
incr warnings
}
if {$compileOrLink == "C"} {
# we have a compile error, so strip out the error message, the filespec
# and the line number
if {[regexp {ErrS:╥(.*)╙.*╟(.*)╚.*ErrL:([0-9]+)} $err unused errorString fileSpec lineNumber]} {
# conver the filespec that was returned in the apple event into a pathname
# so we can display it
set pathName [specToPathName $fileSpec]
# append the file name (the tail of the pathname), the line number,
# the error string, lots of tabs, and then the full pathname
append text "\"[file tail $pathName]\"\t; Line $lineNumber: $errorString\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t░$pathName\r"
}
} else {
# we got a link error
set link 1
# just strip out the error message. the file the error occurs in doesn't
# seem to get included in the event
if {[regexp {ErrS:╥(.*)╙} $err unused errorString]} {
# append the error message
append text "$errorString\r"
}
}
} elseif {[regexp {╥([^:]*): (.*)╙} $err unused fileName message]} {
# we got some sort of message, so strip out the associated file name and
# the message. I'm not sure if CodeWarrior still returns anything of this form.
append text "\"$fileName\" ; $message\r"
incr messages
}
}
set wins [winNames]
if {$errors == 0 && $warnings == 0 && $messages == 0} {
global killCompilerErrors
set killCompilerErrors 1
return
}
new -n {* Compiler Errors *} -g $tileLeft $tileTop $tileWidth $errorHeight
changeMode [set winModes([lindex [winNames] 0]) Brws]
if {$link} {
insertText "(Link: $errors errors, $warnings warnings, $messages messages)\r-----\r$text"
} else {
insertText "($errors errors, $warnings warnings, $messages messages: <cr> to go to line)\r-----\r$text"
}
display 0
goto 0
downBrowse
setWinInfo dirty 0
setWinInfo read-only 1
}
}
proc cwTouch {} {
global CODEWarrior CWCLASS
checkCw
switchTo $CODEWarrior
set fname [lindex [winNames -f] 0]
set res [AEBuild -t 500000 -q $CODEWarrior $CWCLASS "Toch" "----" [makeAlis $fname]]
}
proc checkCw {} {
global CODEWarrior modifiedVars cwSig cwPath
set CODEWarrior [checkRunning "CodeWarrior Compiler" $cwSig cwPath]
set sig [getFileSig $cwPath]
if {$sig != $cwSig} {
lappend modifiedVars cwSig
set cwSig $sig
}
}
proc checkCwDebug {} {
global CODEDEBUGGER cwdSig cdPath modifiedVars
set CODEDEBUGGER [checkRunning "CodeWarrior Debugger" $cwdSig cdPath]
set sig [getFileSig $cdPath]
if {$sig != $cwdSig} {
lappend modifiedVars cwdSig
set cwdSig $sig
}
}
proc cwgotoDebugger {} {
global CODEDEBUGGER
checkCwDebug
switchTo $CODEDEBUGGER
}
proc cwsetBreakpoint {} {
global CODEDEBUGGER CDCLASS res
checkCwDebug
switchTo $CODEDEBUGGER
set fname [lindex [winNames -f] 0]
set ln [lindex [posToRowCol [getPos]] 0]
set res [AEBuild -t 500000 -r $CODEDEBUGGER $CDCLASS "Sbrk" "----" [makeAlis $fname] "Line" "long($ln)"]
}
proc cwclearBreakpoint {} {
global CODEDEBUGGER CDCLASS res
checkCwDebug
switchTo $CODEDEBUGGER
set fname [lindex [winNames -f] 0]
set ln [lindex [posToRowCol [getPos]] 0]
set res [AEBuild -t 500000 -r $CODEDEBUGGER $CDCLASS "Cbrk" "----" [makeAlis $fname] "Line" "long($ln)"]
}
proc cwshowSource {} {
global CODEDEBUGGER CDCLASS res
checkCwDebug
switchTo $CODEDEBUGGER
set fname [lindex [winNames -f] 0]
set ln [lindex [posToRowCol [getPos]] 0]
set res [AEBuild -t 500000 -r $CODEDEBUGGER $CDCLASS "Show" "----" [makeAlis $fname] "Line" "long($ln)"]
}
# "Soff" "long([getPos]" "Eoff" "long([selEnd])"